<template>
	<view class="content">
		<view>
			犬只名称
			<text class="huang">※</text>
		</view>
		<input type="text" v-model="name" placeholder="请输入犬只名称" />
		<view>
			养犬人身份证号（法人身份证号）
			<text class="huang">※</text>
		</view>
		<input type="text" v-model="idCard" placeholder="请输入身份证号" />
		<view @tap="go" class="btn"><button type="default" style="background-color:#fcd700;">查询</button></view>
		<view class="tip" v-if="Data">
			<view>
				<text class="text">审核状态:</text>
				{{ Data.examine }}
			</view>
			<!-- <view>
				<text class="text">审核姓名:</text>
				{{ Data.userName }}
			</view> -->
			<view>
				<text class="text">审核意见:</text>
				{{ Data.shyj }}
			</view>

			<button @tap="guan" type="primary" style="background-color:#fcd700;padding: 0 60upx;">确定</button>
		</view>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import CHONG from '../../static/js/function.js';
	import IdCard from '../../static/js/IdCard.js';
export default {
	computed: mapState(['URL']),
	data() {
		return {
			name: '',
			idCard: '',
			Data: '',
		};
	},
	methods: {
		go() {
			if (!this.name) {
				CHONG.tip('请填写养只名字', 1);
				return;
			} else if (!this.idCard) {
				CHONG.tip('请填写身份证号', 1);
				return;
			}else if (IdCard.cnid(this.idCard) !== true) {
				CHONG.tip('请填写正确格式的身份证号', 1);
				return;
			}
			CHONG.tip('查询中', 0);
			let data = {
				dogName: this.name,
				idCard: this.idCard
			};

			uni.request({
				url: this.URL + 'applying',
				data: data,
				success: res => {
					console.log(json);
					if(!res.data.success){
						CHONG.tip(res.data.msg);
					}
					let json = res.data.data[0];
					if (!json.status) {
						CHONG.tip(json.msg);
						return;
					}
					this.Data = json;
					uni.hideLoading();
				}
			});
		},
		guan() {
			this.Data = null;
			this.name = '';
			this.idCard = '';
		}
	}
};
</script>

<style lang="scss">
.content {
	font-size: 26upx;
	padding: 20upx;

	input {
		color: $chong-text-color;
		font-size: 24upx;
		margin: 10upx 0;
		padding: 4upx 20upx;

		border: {
			radius: 10upx;
			style: solid;
			width: 1upx;
			color: rgba($chong-text-color, 0.2);
		}

		background: white;
	}

	.btn {
		padding: 50upx 0;
		margin: 0 140upx;
	}

	.huang {
		color: $chong-iconbg-color;
	}

	.tip {
		width: 690upx;
		height: 500upx;
		position: relative;
		top: -200upx;
		background: white;
		text-align: center;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		margin: 20upx;
		box-shadow: 0px 6px 5px 0px #d1d1d1;
		font-size: 36upx;
		border-radius: 20upx;

		.text {
			color: #888;
			padding-right: 10upx;
		}
	}
}
</style>
